
add_definitions(
    -D__NTDLL__
    -D_NTOSKRNL_
    -DCRTDLL)

include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/rtl)
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/ndk)

spec2def(ntext.dll ntext.spec ADD_IMPORTLIB)

if(ARCH STREQUAL "amd64")
	set(baseaddress_ntext   0x36D60000)
elseif(ARCH STREQUAL "i386")
	set(baseaddress_ntext   0x7DD60000)
endif()

list(APPEND SOURCE
	crypt.c
    main.c
	sqm.c
	misc.c
	csr/api.c	
	csr/capture.c	
	etw/etw.c	
    etw/trace.c	####### this is a only test ########
	ntapi/alpc.c	
	ntapi/hooks.c	
	ntapi/ntapi.c	
	ldr/ldrapi.c
	ldr/loader.c
	#ldr/toolhelp.c
	rtl/acl.c
	rtl/actctx.c
	rtl/atom.c
	rtl/avl.c	
	rtl/boundary.c
	rtl/cache.c
	rtl/context.c
	rtl/critical.c
	rtl/environ.c
	rtl/error.c
	rtl/exception.c
	rtl/heap.c
	rtl/hooks.c
	rtl/imagedir.c
	rtl/interlck.c
	rtl/ldrrsrc.c
	rtl/loader.c
	rtl/locale.c
	rtl/misc.c
	rtl/nls.c
	rtl/notification.c
    rtl/path.c
	rtl/pointer.c
	rtl/processor.c
	rtl/profiling.c
	rtl/sid.c	
	rtl/sxs.c
	rtl/synch.c		
	rtl/sysinfo.c
	rtl/time.c
	rtl/transaction.c
	rtl/thread.c
	rtl/threadpool.c
	rtl/unicode.c
	rtl/wer.c
	rtl/wow64.c
	rtl/virtual.c
    version.rc
    ${CMAKE_CURRENT_BINARY_DIR}/ntext_stubs.c
    ${CMAKE_CURRENT_BINARY_DIR}/ntext.def)
	
	
if(ARCH STREQUAL "amd64")
    list(APPEND SOURCE
        rtl/amd64/dynfntbl.c
		)
endif()		

add_library(ntext SHARED ${SOURCE})

set_module_type(ntext win32dll ENTRYPOINT LdrInitialize 12 UNICODE)
#############################################
## HACK FOR MSVC COMPILATION WITH win32dll ##
set_subsystem(ntext console)
################# END  HACK #################

if(MSVC)
    add_target_link_flags(ntext "/RELEASE")
endif()

if(MSVC_IDE)
	add_compile_options(/Ox /Ob2 /Ot /Oy)
endif()

target_link_libraries(ntext libcntpr uuid ${PSEH_LIB})

add_importlibs(ntext ntdll)

add_cd_file(TARGET ntext DESTINATION reactos/system32 FOR all)
